class StockMaterialcheckitem {
  String? id;
  String? checkId;
  String? warehouseId;
  String? warehouseName;
  String? materialId;
  String? stockqty;
  String? createUid;
  String? createDate;
  String? writeUid;
  String? writeDate;
  String? productName;
  String? productCode;
  String? productDesc;
  String? unit;
  String? locationId; // 库房
  String? locationCode; // 库房
  String? locationName; // 库房
  String? shelvesName; // 库位
  String? productorderno; // 生产单号
  String? batchno; // 批次
  String? planQty; // 计划数量
  String? remark; // 备注
  String? isCheck; // 是否盘点
  String? profit; // 是否盘点
  String? loss; // 是否盘点

  StockMaterialcheckitem({
    this.id,
    this.checkId,
    this.warehouseId,
    this.warehouseName,
    this.materialId,
    this.stockqty,
    this.createUid,
    this.createDate,
    this.writeUid,
    this.writeDate,
    this.productCode,
    this.productDesc,
    this.productName,
    this.unit,
    this.locationId,
    this.locationCode,
    this.locationName,
    this.shelvesName,
    this.productorderno,
    this.batchno,
    this.planQty,
    this.remark,
    this.isCheck,
    this.profit,
    this.loss,
  });

  StockMaterialcheckitem copyWith({
    String? id,
    String? checkId,
    String? warehouseId,
    String? materialId,
    String? stockqty,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
  }) {
    return new StockMaterialcheckitem(
      id: id ?? this.id,
      checkId: checkId ?? this.checkId,
      warehouseId: warehouseId ?? this.warehouseId,
      materialId: materialId ?? this.materialId,
      stockqty: stockqty ?? this.stockqty,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
    );
  }

  @override
  String toString() {
    return '''StockMaterialcheckitem{
      id: id,
      checkId: checkId,
      warehouseId: warehouseId,
      materialId: materialId,
      stockqty: stockqty,
      createUid: createUid,
      createDate: createDate,
      writeUid: writeUid,
      writeDate: writeDate,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is StockMaterialcheckitem &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          checkId == other.checkId &&
          warehouseId == other.warehouseId &&
          materialId == other.materialId &&
          stockqty == other.stockqty &&
          createUid == other.createUid &&
          createDate == other.createDate &&
          writeUid == other.writeUid &&
          writeDate == other.writeDate);

  factory StockMaterialcheckitem.fromMap(Map<String, dynamic> map) {
    return new StockMaterialcheckitem(
      id: map['id'] != false ? map['id'].toString() as String? : "",
      checkId:
          map['check_id'] != false ? map['check_id'][0].toString() as String? : "",
      // warehouseId: map['warehouse_id'] != false
      //     ? map['warehouse_id'][0].toString() as String?
      //     : "",
      // warehouseName: map['warehouse_id'] != false
      //     ? map['warehouse_id'][1].toString() as String?
      //     : "",
      materialId: map['material_id'] != false
          ? map['material_id']['id'].toString() as String?
          : "",
      stockqty:
          map['stockqty'] != false ? map['stockqty'].toString() as String? : "",
      createUid: map['create_uid'] != false
          ? map['create_uid'][0].toString() as String?
          : "",
      // createDate: map['create_date'] != false
      //     ? map['create_date'].toString() as String?
      //     : "",
      productCode: map['material_id']['default_code'] != false
          ? map['material_id']['default_code'].toString() as String?
          : "",
      productName: map['material_id']['name'] != false
          ? map['material_id']['name'].toString() as String?
          : "",
      productDesc: map['material_id']['description'] != false
          ? map['material_id']['description'].toString() as String?
          : "",
      unit: map['material_id']['uom_id'] != false
          ? map['material_id']['uom_id'][1].toString() as String?
          : "",
      locationId: map['location_id'] != false
          ? map['location_id'][0].toString() as String?
          : "",
      locationName: map['location_name'] != false
          ? map['location_name'].toString() as String?
          : "",
      shelvesName: map['shelves_name'] != false
          ? map['shelves_name'].toString() as String?
          : "",
      productorderno: map['productorderno'] != false
          ? map['productorderno'].toString() as String?
          : "",
      batchno: map['batchno'] != false
          ? map['batchno'].toString() as String?
          : "",
      planQty: map['plan_qty'] != false
          ? map['plan_qty'].toString() as String?
          : "",
      remark: map['remark'] != false
          ? map['remark'].toString() as String?
          : "",
      isCheck: map['is_heck'] != false
          ? map['is_check'].toString() as String?
          : "0",
      profit: map['profit'] != false
          ? map['profit'].toString() as String?
          : "",
      loss: map['loss'] != false
          ? map['loss'].toString() as String?
          : "",
    );
  }

  factory StockMaterialcheckitem.fromItemInfoMap(Map<String, dynamic> map) {
    return new StockMaterialcheckitem(
      id: map['id'] != false && map['id'] != null ? map['id'].toString() as String? : null,
      materialId: map['material_id'] != false
          ? map['material_id'][0].toString() as String?
          : "",
      stockqty:
          map['stockqty'] != false ? map['stockqty'].toString() as String? : "",
      productCode: map['product_default_code'] != false
          ? map['product_default_code'].toString() as String?
          : "",
      productName: map['product_name'] != false
          ? map['product_name'].toString() as String?
          : "",
      productDesc: map['product_desc'] != false
          ? map['product_desc'].toString() as String?
          : "",
      unit: map['unit_name'] != false
          ? map['unit_name'].toString() as String?
          : "",
      locationId: map['location_id'] != false
          ? map['location_id'][0].toString() as String?
          : "",
      locationName: map['location_name'] != false
          ? map['location_name'].toString() as String?
          : "",
      shelvesName: map['shelves_name'] != false
          ? map['shelves_name'].toString() as String?
          : "",
      productorderno: map['productorderno'] != false
          ? map['productorderno'].toString() as String?
          : "",
      batchno: map['batchno'] != false
          ? map['batchno'].toString() as String?
          : "",
      planQty: map['plan_qty'] != false
          ? map['plan_qty'].toString() as String?
          : "",
      remark: map['remark'] != false && map['remark'] != null
          ? map['remark'].toString() as String?
          : "",
      isCheck: map['is_heck'] != false
          ? map['is_check'].toString() as String?
          : "0",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'productorderno': this.productorderno,
      'batchno': this.batchno,
      'locationName': this.locationName,
      'shelvesName': this.shelvesName,
      'productCode': this.productCode,
      'productName': this.productName,
      'productDesc': this.productDesc,
      'unit': this.unit,
      'planQty': this.planQty,
      'stockqty': this.stockqty,
      'loss': this.loss,
      'profit': this.profit,
      'remark': this.remark,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.checkId != null && this.checkId != '')
        ['check_id', '=', int.parse(this.checkId!)],
      if (this.productorderno != null && this.productorderno != '')
        ['productorderno', '=', productorderno],
      if (this.productCode != null && this.productCode != '')
        ['material_id.default_code', '=', productCode],
      if (this.locationCode != null && this.locationCode != '')
        ['location_id.location_code', '=', locationCode],
    ];

    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'check_id': this.checkId,
      'material_id': this.materialId,
      'stockqty': this.stockqty,
      'plan_qty': this.planQty,
      'remark': this.remark,
      'batchno': this.batchno,
      'productorderno': this.productorderno,
      'location_id': this.locationId,
      'location_name': this.locationName,
      'shelves_name': this.shelvesName,
      'is_check': this.isCheck,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}
